<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
 <!-- 增加学期计划 -->
		<div id="dialog-message">
		        <div id="sys_learnPlantFrom">
				<input type="hidden" id="plpid" name="plpid" value="${param.lpid}">
				 <input type="hidden" id="pltype" name="pltype" value="">
				 <input type="hidden" id="pName" name="pNmae" value="${param.pName}">
				 <table  class="table table-striped table-hover table-bordered">
					 <tr>
				 		<td>计划类型:</td>
				 		<td colspan="2" id="ptype_1"></td>
				 	</tr>
					 
					 <tr>
						<td>环节类型:</td>
				 		<td colspan="2" id="pltype_1"> <input type="radio" checked="checked" value="0" name="pltype_1">上课环节<input type="radio" value="1" name="pltype_1">作业环节
						</td>
				 	 </tr>
					 
					 <tr>
						<td>是否共享:</td>
				 		<td colspan="2" id="share"> <input type="radio" checked="checked" value="0" name="share">不共享<input type="radio" value="1" name="share">共享
						</td>
				 	 </tr>
					 
				 	 <tr>
				 		<td>备课计划目录:</td>
				 		<td colspan="2">${param.pName}</td> 
				 	 </tr>
				 	  <tr>
				 		<td>名称:</td>
				 		<td colspan="2"><input type="text" require='true' meth="notNull" maxlength="20" title="此项不能为空!" id="name" name="name"></td> 
				 	 </tr>
					  <tr>
				 		<td>上课时间:</td>
						<td></td>
				 		<td><button class="btn btn-primary" id="selectKebiao">查询课表</button></td> 
				 	 </tr>
					   <tr>
				 		<td>作业卷:</td>
						<td></td>
				 		<td><button class="btn btn-primary" id="addPlanrt_juan">增加卷</button></td> 
				 	 </tr>
				 	<tr>
				 		<td>备课目标:</td>
				 		<td id=""><p id="learnPlant_addClass_show"></p></td>
				 		<td><button class="btn btn-primary" id="learnPlant_addClass">选择集团</button></td>
				 	</tr>
				 	<tr>
				 		<td>备课标签:</td>
				 		<td id=""><p id="learnPlant_addLable_show"></p></td>
				 		<td><button class="btn btn-primary" style="margin-top:4px;" id="learnPlant_addLable">选择标签</button>
				 			<button class="btn btn-primary" style="margin-top:4px;" id="learnPlant_addLable1">增加标签</button>
				 		</td>
				 	</tr>
					
				 	 <tr id="contentLv4">
				 		<td>备课计划内容:</td>
				 		<td colspan="2"><textarea style="width:300px;height:100px;" id="content"></textarea></td>
				 	</tr>
				 	 <tr id="contentLv5">
				 		<td>备课计划教具:</td>
				 		<td colspan="2"><textarea style="width:300px;height:100px;" id="jiaoju"></textarea></td>
				 	</tr>
				 
				 	<tbody id="childrenLv5_1">
					 	<tr>
					 		<td colspan="3">教学步骤: <button id="add_jiaoxuebuzhou" class="btn btn-danger btn-sm"><i class="icon-edit icon-only"></i></button>
					 		</td> 
					 	</tr>
				 		<tr>
				 			<td colspan="3"> 
				 				<table id="childrenLv5" class="table table-striped table-hover table-bordered">
				 					<tr>
							 			<td>名称</td>
							 			<td>时长</td>
							 			<td>内容</td>
							 			<td>附件</td>
							 			<td>标签</td>
							 			<td>场地</td>
							 			<td>教学器材</td>
							 			<td>操作</td>
							 		</tr> 
				 				</table> 
				 			</td>
				 		</tr>
				 	</tbody>
				 	 <tr>
				 		<td>场地:</td>
				 		<td colspan="2"><input type="text" id="adress" name="adress"/></td>
				 	</tr>
				 	 <tr>
				 		<td>所需要课时:</td>
				 		<td colspan="2"><input type="text" id="keshi" require='true' meth="notNull,isNumber" title="只能输入数字" name="keshi"/></td>
				 	</tr>
				 	 <tr>
				 		<td>时长:</td>
				 		<td colspan="2"><input type="text" id="learntime" require='true' meth="notNull,isNumber" title="只能输入数字" name="learntime"/></td>
				 	</tr>
				 	 <tr>
				 		<td>附件:</td>
				 		<td colspan="2"><input type="text" id="fujian" name="fujian"/>当前为后台，附件必须是URL地址的形式</td>
				 	</tr>
				 </table>					 
			</div>
	</div>
			
<div id="learnPlantAdd_ClassWindow">


</div>
			<!-- 增加用户结束-->
<script>
(function(){
	//增加学期计划
	 function addlearnPlant(contrl){
		var a =$("#sys_learnPlantFrom").hzValidate("init");  
		if(a==false){
			return;
		}else{
		  
			var classbuton = $("button[name=classbuton]");
			var lablebuton = $("button[name=lablebuton]");
			var object = OAajaxSubmit("sys_learnPlantFrom"); 
			
			//得到所有的班级
			if(classbuton.length>0){
				var arrclass = new Array();
				for(var i=0;i<classbuton.length;i++){
					var object1 = new Object();
					object1.table_id = $(classbuton[i]).attr("table_id");
					arrclass.push(object1);
				}
				object.arrclass = obj2str(arrclass);
			}
			//得到所有的标签
			if(lablebuton.length>0){
				var arrlable = new Array();
				for(var i=0;i<lablebuton.length;i++){
					var object1 = new Object();
					object1.table_id = $(lablebuton[i]).attr("table_id");
					arrlable.push(object1);
				}
				object.arrlable = obj2str(arrlable);
			}  
			 object.id1 ="${param.id1}";
			 object.id2 ="${param.id2}";
			 object.id3 ="${param.id3}";
			 object.id4 ="${param.id4}";
			 object.id5 ="${param.id5}";
			 
			 //如果是4，表示要带步骤过去
			 if($("#pltype").val()==4){
				var buzhoutr = $("tr[name=buzhoutr]");
				if(buzhoutr.length>0){
					var children = new Array();
					 for(var i=0;i<buzhoutr.length;i++){ 
						 children.push($(buzhoutr[i]).data("pl")); 
					 }
					 object.children =obj2str(children);
					  
				} 
				//拿到排课的类型
				var radio = $("[name=pltype_1]");
				for(var i=0;i<radio.length;i++){
					if($(radio[i])[0].checked==true){
						object.pltype_1=$(radio[i]).attr("value");
						break;
					}
				} 
				//拿到是不是共享 
				var shareradio = $("[name=share]");
				for(var i=0;i<shareradio.length;i++){
					if($(shareradio[i])[0].checked==true){
						object.share=$(shareradio[i]).attr("value");
						break;
					}
				} 
				if(object.pltype_1 =="0"){
					//拿到课表
					 var classC =$("#selectKebiao").data("class");
					 if(classC && classC!=null){
						 object.classC = obj2str(classC);
						 
					 }
				}
				if(object.pltype_1 =="1"){
					//拿到作业
					 var testpaper =$("#addPlanrt_juan").data("testpaper");
					 if(testpaper && testpaper!=null){
						 object.testpaper = obj2str(testpaper);
					 }
				}
			 } 
			var url ="${pageContext.request.contextPath}/edu/sys_LearnPlantAction.do?method=addSys_LearnPlant"; 
				$.ajax({
					   type: "POST",
					   url: url,
					   data: object,
					   dataType:'json',
					   success: function(msg){
					     	alert(msg.message);
					     	if(msg.code==1){
					     		//window.lable.loadTree();
					     		//window.lable.loadLable(null,{});
					     		$(contrl).dialog('destroy'); 
								$("#user_include").html("");
								window.learnPlant.loadTree();
					     	} 
					   }
				}); 
		}
	 };
	 //增加班级
	 $("#learnPlant_addClass").click(function(){
		 $("#learnPlantAdd_ClassWindow").html("");
		 	$("#learnPlantAdd_ClassWindow").load("${pageContext.request.contextPath}/learnPlantAdd_Class.jsp?r="+Math.random(),{},function(){		 		 
		 		var dialog = $("#dialog-message_class").removeClass("hide").dialog({
					modal: true,
					title: "备课计划目标对象",
					width:800,
					title_html: false,
					close:function(){
						$(this).dialog('destroy'); 
						$("#learnPlantAdd_ClassWindow").html("");
					},
					buttons: [  
						{
							text: "提交",
							"class" : "btn btn-primary btn-xs",
							click: function() {
								window.dialog_message_class.addLearnPlantClass(this);
							} 
						}
					]
				}); 
			}); 
	 });
	 //显示作业弹窗
	 $("#addPlanrt_juan").click(function(){ 
			$("#learnPlantAdd_ClassWindow").html("");
			$("#learnPlantAdd_ClassWindow").load("${pageContext.request.contextPath}/learnPlant_homeWork.jsp?r="+Math.random(),function(){
				var dialog = $("#learnPlantAdd_ClassWindow").removeClass("hide").dialog({
					modal: true,
					title: "加入作业",
					width:1000,
					height:600,
					title_html: false,
					close:function(){
						$(this).dialog('destroy'); 
						$("#learnPlantAdd_ClassWindow").html("");
						//loadTree();
					},
					buttons: [  
						{
							text: "提交",
							"class" : "btn btn-primary btn-xs",
							click: function() { 
								window.learnPlant_homeWork.createHomeWorkLearnPlant(this);
								// $(this).dialog('destroy'); 
								//$("#learnPlantAdd_ClassWindow").html("");
							} 
						}
					]
				}); 
			}); 
	 });
	//增加标签
	 $("#learnPlant_addLable").click(function(){
		 $("#learnPlantAdd_ClassWindow").html("");
		 	$("#learnPlantAdd_ClassWindow").load("${pageContext.request.contextPath}/learnPlantAdd_Lable.jsp?r="+Math.random(),{},function(){		 		 
		 		var dialog = $("#dialog-message_class").removeClass("hide").dialog({
					modal: true,
					title: "增加备课计划标签",
					width:800,
					title_html: false,
					close:function(){
						$(this).dialog('destroy'); 
						$("#learnPlantAdd_ClassWindow").html("");
						//loadTree();
					},
					buttons: [  
						{
							text: "提交",
							"class" : "btn btn-primary btn-xs",
							click: function() {
								window.dialog_message_lable.addLearnPlantLable(this);
							} 
						}
					]
				}); 
			}); 
	 });
	 
	//增加标签 页面
	$("#learnPlant_addLable1").click(function(){
			$("#learnPlantAdd_ClassWindow").html("");
		 	$("#learnPlantAdd_ClassWindow").load("${pageContext.request.contextPath}/learnPlantAdd_Lable_create.jsp?r="+Math.random(),{},function(){		 		 
		 		var dialog = $("#dialog-message_class").removeClass("hide").dialog({
					modal: true,
					title: "增加标签",
					width:800,
					title_html: false,
					close:function(){
						$(this).dialog('destroy'); 
						$("#learnPlantAdd_ClassWindow").html("");
						//loadTree();
					},
					buttons: [  
						{
							text: "提交",
							"class" : "btn btn-primary btn-xs",
							click: function() {
								window.learnPlantAdd_Lable_create.addLearnPlantLable(this);
							} 
						}
					]
				}); 
			});  
	});
	//点击显示课表
	$("#selectKebiao").click(function(){ 
			if("${sessionScope.sysUser.userType}"=="5"){
				alert("专家不能进行课程的具体上课设置");
				return;
			}
			$("#learnPlantAdd_ClassWindow").html("");
		 	$("#learnPlantAdd_ClassWindow").load("${pageContext.request.contextPath}/teacherWeekPlantWindow.jsp?r="+Math.random(),{},function(){		 		 
		 		var dialog = $("#learnPlantAdd_ClassWindow").removeClass("hide").dialog({
					modal: true,
					title: "加入课表",
					width:800,
					title_html: false,
					close:function(){
						$(this).dialog('destroy'); 
						$("#learnPlantAdd_ClassWindow").html("");
						//loadTree();
					},
					buttons: [  
						{
							text: "提交",
							"class" : "btn btn-primary btn-xs",
							click: function() {
								$(this).dialog('destroy'); 
								$("#learnPlantAdd_ClassWindow").html("");
								//window.learnPlantAdd_Lable_create.addLearnPlantLable(this);
							} 
						}
					]
				}); 
			});  
		
	});
	//计算页面加载 状态
	function loadPageState(){
		var ptype="${param.pltype}";
		if(ptype==""  ){
			$("#pltype").val("1");
			$("#ptype_1").text("科目");
			$("#keshi").parent().parent().remove();
			$("#learntime").parent().parent().remove();
			$("#plpid").val("0");
			$("#childrenLv5_1").remove();
			$("#adress").parent().parent().remove();
			$("#keshi").remove();
			$("#pltype_1").parent().remove();
			$("#selectKebiao").parent().parent().remove();
			$("#share").parent().remove();
		}else if(ptype=="1"){
			$("#pltype").val("2");
			$("#ptype_1").text("模块");
			$("#keshi").parent().parent().remove();
			$("#learntime").parent().parent().remove();
			$("#childrenLv5_1").remove();
			$("#adress").parent().parent().remove();
			$("#keshi").remove();
			$("#pltype_1").parent().remove();
			$("#selectKebiao").parent().parent().remove();
			$("#share").parent().remove();
		}else if(ptype=="2"){
			$("#pltype").val("3");
			$("#ptype_1").text("话题");
			$("#keshi").parent().parent().remove();
			$("#learntime").parent().parent().remove();
			$("#childrenLv5_1").remove();
			$("#adress").parent().parent().remove();
			$("#keshi").remove();
			$("#pltype_1").parent().remove();
			$("#selectKebiao").parent().parent().remove();
			$("#share").parent().remove();
		}else if(ptype=="3"){
			$("#pltype").val("4");
			$("#ptype_1").text("环节"); 
			$("#learntime").parent().parent().remove();
			$("#contentLv4").remove();
			$("#contentLv5").remove(); 
			
		}else if(ptype=="4"){
			$("#pltype").val("5");
			$("#ptype_1").text("步骤");
			$("#keshi").parent().parent().remove(); 
			$("#pltype_1").parent().remove();
			$("#selectKebiao").parent().parent().remove();
		} 
		$("#addPlanrt_juan").parent().parent().hide();
		$("[name=pltype_1]").click(function(){
			var value =$(this).attr("value");
			if(value==1){
				$("#childrenLv5_1").hide();
				$("#addPlanrt_juan").parent().parent().show();
				$("#selectKebiao").parent().parent().hide();
				$("#share").parent().hide();
			}else{
				$("#childrenLv5_1").show();
				$("#selectKebiao").parent().parent().show();
				$("#addPlanrt_juan").parent().parent().hide();
				$("#share").parent().show();
			}
		});
	};
	//增加步骤的显示条件
	function loadbuzhou(){
		var buzhou =$("#add_jiaoxuebuzhou");
		if(buzhou.length>0){
			buzhou.click(function(){
				    $("#learnPlantAdd_ClassWindow").html("");
				 	$("#learnPlantAdd_ClassWindow").load("${pageContext.request.contextPath}/learnPlantAdd_Lable_buzhou.jsp?r="+Math.random(),{id1:"${param.id1}"},function(){		 		 
				 		var dialog = $("#dialog-message_class").removeClass("hide").dialog({
							modal: true,
							title: "增加步骤",
							width:800,
							height:500,
							title_html: false,
							close:function(){
								$(this).dialog('destroy'); 
								$("#learnPlantAdd_ClassWindow").html("");
								//loadTree();
							},
							buttons: [  
								{
									text: "增加步骤",
									"class" : "btn btn-primary btn-xs",
									click: function() {
										window.learnPlantAdd_Lable_buzhou.addbuZhou(this);
									} 
								}
							]
						}); 
					});   
			});
		}
	};
	//加载 
	$(function(){  
		loadPageState();
		loadbuzhou();
	});
	 window.learnPlantAdd={}; 
	 window.learnPlantAdd.addlearnPlant=addlearnPlant;
})()

</script>